<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>td{width: 100px}</style>
</head>
<body>
<table border="1">
    <caption>个人详情</caption>
    <tr><td>照片:</td><td id="pic_td"></td></tr>
    <tr><td>姓名:</td><td id="name_td"></td></tr>
    <tr><td>年龄:</td><td id="age_td"></td></tr>
    <tr><td>好友:</td><td id="friend_td"></td></tr>
</table>
<input type="button" value="加载数据" onclick="f()">
<script>
    //得到页面中的所有td
    let picTd = document.querySelector("#pic_td");
    let nameTd = document.querySelector("#name_td");
    let ageTd = document.querySelector("#age_td");
    let friendTd = document.querySelector("#friend_td");
    function f() {
        //模拟从服务器得到的数据
        let person = {name:"罗宾",age:18,imgUrl:"a.png",friends:["路飞","娜美","索隆"]}
        //把数据显示到页面中
        nameTd.innerText = person.name;
        ageTd.innerText = person.age;
        let img = document.createElement("img");
        img.src = person.imgUrl;
        img.width = 100;
        picTd.append(img);

        let ul = document.createElement("ul");
        //遍历
        for (const friendName of person.friends) {
                let li = document.createElement("li");
                li.innerText = friendName;
                ul.append(li);
        }
        friendTd.append(ul);

    }
</script>
</body>
</html>